<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/html">
<head>
    <!--<bgsound src="/告白气球.mp3" autostart=true loop=infinite></bgsound>-->

    <!--<embed src="/告白气球.mp3" hidden="true" autostart="true" loop="true">-->
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>Johnny❤Rae</title>

    <style type="text/css">
        @font-face {
            font-family: digit;
            src: url('digital-7_mono.ttf') format("truetype");
        }
    </style>

    <link href="/css/default.css" type="text/css" rel="stylesheet">
    <script type="text/javascript" src="/js/jquery.js"></script>
    <script type="text/javascript" src="/js/garden.js"></script>
    <script type="text/javascript" src="/js/functions.js"></script>

</head>

<body>

<div id="mainDiv">

    <div id="content" style="margin-top: 0px">

        <div id="code" style="margin-top: 0px">
            <span style="color: #ff62f1;margin-top: 0px">
                public class MyFirst { <br/>
                &nbsp; &nbsp;public static void main(String[] args) {<br/>
        &nbsp; &nbsp; &nbsp; System.out.println("Hello, World");<br/>
                &nbsp; &nbsp; }<br/>
                }
            </span><br/><br/>

            Boy name = <span class="keyword">Johnny</span> <br/>
            Girl name = <span class="keyword">Rae</span><br/>
            <span class="comments">// Fall in love river. </span><br/>
            The boy love the girl;<br/>
            <span class="comments">// They love each other.</span><br/>
            The girl loved the boy;<br/>
            <span class="comments">// AS time goes on.</span><br/>
            The boy can not be separated the girl;<br/>
            <span class="comments">// At the same time.</span><br/>
            The girl can not be separated the boy;<br/>
            <!-- <span class="comments">// Both wind and snow all over the sky.</span><br/>
             <span class="comments">// Whether on foot or 5 kilometers.</span><br/>-->
            <span class="keyword">The boy</span> very <span class="keyword">happy</span>;<br/>
            <span class="keyword">The girl</span> is also very <span class="keyword">happy</span>;<br/>
            <span class="placeholder"/><span class="comments">// Whether it is right now</span><br/>
            <span class="placeholder"/><span class="comments">// Still in the distant future.</span><br/>
            <span class="placeholder"/>The boy has but one dream;<br/>
            <span class="comments">// The boy wants the girl could well have been happy.</span><br/>
            I want to say:<br/>
            <span class="keyword" style="font: bold">Rururu, I love you forever;<br/></span>
            <!--   <img src="/images/WechatIMG93.jpeg" alt="" width="200"/>-->
        </div>
        <div id="loveHeart">
            <canvas id="garden"></canvas>
            <div id="words">
                <div id="messages">
                    亲爱的，这是我们相爱在一起的时光。
                    <div id="elapseClock"></div>
                </div>
                <div id="loveu">
                    love you ru me, always care about you ~.<br/>
                    <div class="signature">--johnny</div>
                </div>
            </div>
        </div>
    </div>
    <div id="copyright">
        <a href="../美丽可爱小茹茹">System.out.println("Hello, World")</a><br/>
        <a href="javascript:void(0);" onclick="playEndedHandler()">周强❤陈茹</a><br/>
    </div>
</div>
<div id="audioBox"></div>
<script type="text/javascript">
    var arr = ["/music/慢慢喜欢你.mp3", "/music/终于等到你.mp3", "/music/最重要的小事-五月天.mp3", "/music/告白气球.mp3", "/music/forever.mp3", "/music/LoveParadise.mp3"];
    var myAudio = new Audio();
    window.onload = function () {
        myAudio.id = "audio";
        myAudio.preload = true;
        console.log(arr);
        // myAudio.controls = true;
        myAudio.src = arr.pop();
        console.log(arr.length);//每次读数组最后一个元素
        myAudio.addEventListener('ended', playEndedHandler, false);
        myAudio.play();
        document.getElementById("audioBox").appendChild(myAudio);
        myAudio.loop = false;//禁止循环，否则无法触发ended事件
        function playEndedHandler() {

            myAudio.src = arr.pop();
            console.log(arr.length);
            if (arr.length === 0) {
                arr.push("/music/慢慢喜欢你.mp3", "/music/终于等到你.mp3", "/music/LoveParadise.mp3", "/music/forever.mp3", "/music/告白气球.mp3", "/music/最重要的小事-五月天.mp3")
            }
            console.log(arr)
            myAudio.play();

            // !arr.length && myAudio.removeEventListener('ended',playEndedHandler,false);//只有一个元素时解除绑定
        }

        //--创建页面监听，等待微信端页面加载完毕 触发音频播放
        document.addEventListener('DOMContentLoaded', function () {
            function audioAutoPlay() {
                var audio = document.getElementById('audio');
                audio.play();
                document.addEventListener("WeixinJSBridgeReady", function () {
                    audio.play();
                }, false);
            }

            audioAutoPlay();
        });

        //--创建触摸监听，当浏览器打开页面时，触摸屏幕触发事件，进行音频播放
        function audioAutoPlay() {
            var audio = document.getElementById('audio');
            audio.play();
            document.removeEventListener('touchstart', audioAutoPlay);
        }

        document.addEventListener('touchstart', audioAutoPlay);
    }

    function playEndedHandler() {

        myAudio.src = arr.pop();
        console.log(arr.length);
        if (arr.length === 0) {
            arr.push("/music/慢慢喜欢你.mp3", "/music/终于等到你.mp3", "/music/LoveParadise.mp3", "/music/forever.mp3", "/music/告白气球.mp3", "/music/最重要的小事-五月天.mp3")
        }
        console.log(arr)
        myAudio.play();

        // !arr.length && myAudio.removeEventListener('ended',playEndedHandler,false);//只有一个元素时解除绑定
    }

    // $("#audio")[0].play();

    var offsetX = $("#loveHeart").width() / 2;
    var offsetY = $("#loveHeart").height() / 2 - 55;
    var together = new Date();
    together.setFullYear(2017, 1, 24);
    together.setHours(19);
    together.setMinutes(5);
    together.setSeconds(2);
    together.setMilliseconds(0);

    if (!document.createElement('canvas').getContext) {
        var msg = document.createElement("div");
        msg.id = "errorMsg";
        msg.innerHTML = "Your browser doesn't support HTML5!<br/>Recommend use Chrome 14+/IE 9+/Firefox 7+/Safari 4+";
        document.body.appendChild(msg);
        $("#code").css("display", "none")
        $("#copyright").css("position", "absolute");
        $("#copyright").css("bottom", "10px");
        document.execCommand("stop");
    } else {
        setTimeout(function () {
            startHeartAnimation();
        }, 5000);

        timeElapse(together);
        setInterval(function () {
            timeElapse(together);
        }, 500);

        adjustCodePosition();
        $("#code").typewriter();
    }
</script>

<!--<video id="audio" src="/告白气球.mp3" autoplay="autoplay" loop="loop"></video>-->
</body>
</html>